<div class="bookDetail">


<div class="bookImg">
<img src="<?php echo $this->bookProfile($this->pageModel->getBook());?>"/>
</div>
<div class="bookDesc">
<h1><?php echo $this->pageModel->getBook()->name;?></h1>
<div class="bookProperty">
<?php if(isset($this->pageModel->getBook()->author)){ ?>
<Strong>Author:</Strong> <?php echo $this->pageModel->getBook()->author;?> <br /><?php }?>


<!--<Strong><?php echo $this->pageModel->getBook()->binding;?>:</Strong> <?php echo $this->pageModel->getBook()->number_of_pages;?> Pages <br />-->
<Strong>Publisher:</Strong> <?php echo $this->pageModel->getBook()->manufacturer;?> (<?php echo $this->pageModel->getBook()->publication_date; ?>)  <br />
<?php 
$isbn = null;

$isbn10 = $this->pageModel->getBook()->ISBN;
if (isset($isbn10) && strlen($isbn10)>0&& !strpos($isbn10, "_fake")){
?><Strong>ISBN-10:</Strong> <?php
$isbn = $isbn10;
echo $isbn10;?>  <br />

<?php }
 $isbn13 = $this->pageModel->getBook()->ISBN13;
if (isset($isbn13) && strlen($isbn13)>0 && !strpos($isbn13, "_fake")){
?>
<Strong>ISBN-13:</Strong> <?php 
$isbn = $isbn13;
echo $isbn13;?> <br />
<?php }?>
<?php if (!empty($isbn)){ ?>
<div style="display:none" id="isbnHidden"><?php echo $isbn;?></div>
<?php } ?>
<?php
$description = $this->pageModel->getBook()->description;
if(isset($description) && strlen($description)>0){ ?>

<Strong>Description:</Strong> 
<div id="bookDescription">
<div class="short"><div style="height:18px;overflow:hidden;"><?php echo $description;?> </div><a href="javascript:void(0)">[More..]</a></div>
<div class="full"><?php echo $description;?> <a href="javascript:void(0)">[..Less]</a></div>
</div>
<?php }?>
<span id="bookPriceBlock">
<?php if ( "manual" == $this->pageModel->getBook()->source) {?>

<?php }else if ( "amazon" == $this->pageModel->getBook()->source){?> 

<Strong>Amazon.com:</Strong> <a target="_blank" href="<?php echo $this->pageModel->getBook()->detail_page_url; ?>">Click here</a>
<?php } ?></span>
</div>
</div>
</div>

<div class="dotline" style="margin-bottom:10px;"></div>
<?php 
//$userData = $this->loggedInUser();
//$user = new User();
//$loginUser = $user->findById($userData->id);
$loginUser = $this->pageModel->getUser();
$userHasBook = false;
if (!empty($loginUser)) {
    $userHasBook = Book::userHasBook($this->pageModel->getBook(), $loginUser);
}

$userCity = $this->userCity();
$bookConditionsAmount = $this->pageModel->getBookConditionsAmount($userCity->id);
?>
<h2 style="margin-bottom:12px;">Showing <?php echo $bookConditionsAmount["New"]?> New, <?php echo $bookConditionsAmount["Used"]?> Used, <?php echo $bookConditionsAmount["eBook"]?> EBook in this area.
<?php if (!$userHasBook) {?>
<a href="<?php echo $this->url(array("controller"=>"book", "action"=>"add", "id"=>$this->pageModel->getBook()->ISBN), "default", true);?>">I also have this book!</a>
<?php } else {?>
You have this book.
<?php }?>
</h2>

<?php
// show users that have the same book.
$users = $this->pageModel->usersHasBook;
if (!empty($users)) {?>
<ul id="bookOwners">

<?php 
	foreach ($users as $user) {
?>
<li>
<div class="ownerImage">
<img src="<?php echo $this->userThumbnail($user);?>" width="50px" height="50px;"></img>
<?php 
$uc = User::checkUserAuthProvider($user, AuthProvider::FACEBOOK);
if (!empty($uc)) {
	$userData = $this->loggedInUser();
	if ($userData != null) {
	?><a target="_blank" id="fbIcon" title="<?php echo $user->name;?> has connected with Facebook, isn't he/she more trustworthy? Click to check out!" href="http://www.facebook.com/profile.php?id=<?php echo $uc->auth_uid;?>">
fb</a><?php
	}else{?>
	<a href="javascript:void(0)" id="fbIcon" title="<?php echo $user->name;?> has connected with Facebook, ONLY Logged in user could check that out!"></a>
	<?php
		
	}
?>

<?php }?>
</div>
<div class="ownerDesc">
<div class="ownerStripe">
<a style="float:left;margin-left:5px;font-size:12px;" href="<?php echo $this->url(array("controller"=>"user", "action"=>"profile", "uid"=>$user->id), "default", true);?>"><?php echo $user->name?></a>
<span style="float:left;margin-left:20px;"><?php echo $this->userLocation($user);?></span>
<?php if (!empty($loginUser) && $user->id == $this->loggedInUser()->id) {?>
<span style="float:right;margin-right:8px;font-size:10px;">This is You, want to <a href="<?php echo $this->url(array("controller"=>"book", "action"=>"edit", "id"=>$this->pageModel->getBook()->ISBN), "default", true);?>">Edit</a> or 
<a href="<?php echo $this->url(array("controller"=>"user", "action"=>"booklist"), "default", true);?>">Change Status</a></span>
<?php } else {?>
<a style="float:right;margin-right:8px;font-size:10px;" href="<?php echo $this->url(array("controller"=>"message", "action"=>"sendmessage", "uid"=>$user->id), "default", false);?>">Send message</a>
<?php }?></div>
<div class="bookStripe">
<?php echo $this->userBookStatusView($this->pageModel->getBook(),$user );?>
</div>
</div>
        
</li>
<?php 
	}?></ul>
<?php }
?>